unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, Grids, DBGrids, ADODB, DBCtrls, TeEngine, Series,
  ExtCtrls, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Memo2: TMemo;
    Chart1: TChart;
    Series1: TLineSeries;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    FStrList : TStringList;
    function SixteenToTen(SourceStr:string):string;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  sStr,sText,sT : String;
  i,iX,iY : Integer;
begin
  Memo2.Lines.Clear;
  sStr := Memo1.Lines.Text;
  FStrList.Clear;

  while Length(sStr)>0 do
  begin
    FStrList.Add(Copy(sStr,1,4));

    Delete(sStr,1,4);
  end;

  Chart1.SeriesList.Series[0].Clear;
//  for i := 0 to 299 do
//    Chart1.SeriesList.Series[0].Add(0);
  for i := 0 to FStrList.Count -1 do
  begin
    sStr := FStrList.Strings[i];
    sT := sStr[1];
    Delete(sStr,1,1);
    sStr := Trim(SixteenToTen(sStr));

    iX := i+1;
    iY := StrToInt(sStr);
    sText := Format('T:%s X:%d Y:%d ',[sT,iX,iY]);
  //  Memo2.Lines.Add(sText);
    Memo2.Lines.Insert(0,sText);

    Chart1.SeriesList.Series[0].Add(0);
    Chart1.SeriesList.Series[0].XValue[i] := iX;
    Chart1.SeriesList.Series[0].YValue[i] := iY;
  end;
  Chart1.SaveToBitmapFile('c:\aaa.bmp');

//  Memo2.Lines.AddStrings(FStrList);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Memo1.Lines.Clear;
  Memo2.Lines.Clear;
  FStrList := TStringList.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FStrList.Free;
end;

function TForm1.SixteenToTen(SourceStr: string): string;
var
  vStr,TmpStr:string;
  i:integer;
begin
  vStr:='';
  TmpStr:='';
  try
    for i:=1 to length(SourceStr) do
    begin
      if SourceStr[i] in ['0'..'9','A'..'F','a'..'f'] then
         TmpStr:=TmpStr+UpperCase(SourceStr[i])
      else
      begin
        if TmpStr<>'' then
           vSTR:=vSTR+IntToStr(StrToInt('$'+TMPSTR))+' ';
        TmpStr:='';
      end;
    end;
    if TmpStr<>'' then
        vSTR:=vSTR+IntToStr(StrToInt('$'+TMPSTR))+' ';
  except
    vStr := '';
  end;
  TmpStr:='';
  Result:=vStr;

end;

end.
